<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of InscricaoDAO
 *
 * @author Albuquerque
 */
require_once "FactoryConnection.php";
class InscricaoDAO {
    //put your code here

    var $conect;
	
    function __construct(){
	$this->conect = FactoryConnection::getConexao();	
    }
    public function salvar($inscricao){
         $query = "INSERT INTO 
                ceape_inscricao(data_hora, referencia, valor, cliente)
                VALUES(
                        '".$inscricao->getData_hora()."',
                        '".$inscricao->getReferencia()."',
                        '".$inscricao->getValor()."',
                        '".$inscricao->getCliente()."'
                )";

        try{
            $this->conect->beginTransaction();
            $sucesso = $this->conect->exec($query);            
            $this->conect->commit();
            } catch (PDOException $ex){
            $this->conect->rollBack();
        }
        
        return $sucesso;
    }

    public function get($id){
        
        $query = "SELECT id FROM ceape_inscricao WHERE id = '".$id."'";
		
        $resultado = $this->conect->query($query);

        if($resultado->rowCount())
                return $resultado->fetchObject();
            return NULL;
    }
}
?>
